Page({

  /**
   * 页面的初始数据
   */
  data: {
    option: '',
    receiver:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var option = JSON.parse(options.presentPackage);
    var price = option.price;
    var prices = price/100;
    option.prices = prices;
    var receiver = JSON.parse(options.receivers);
    var length = receiver.length;

    for (var i = 0; i < length; i++) {
      var receiverMobile = receiver[i].receiverMobile;
      var createDate = receiver[i].createDate;
      if (receiverMobile){
        var mobile = receiverMobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
      }
      console.log(createDate)
      console.log(receiverMobile)
      var times = new Date(createDate).format("yyyy-MM-dd")      
      console.log(mobile)
      receiver[i].times = times;
      receiver[i].mobile = mobile;
    } 
    // var createDate = receiver.createDate;
    // var times = new Date(createDate).format("yyyy-MM-dd");
    // receiver.times = times
   
    console.log(length)
    console.log(receiver)
    console.log(option)
    var updateDate = option.createDate;
    var time = new Date(updateDate).format("yyyy-MM-dd")
    option.time = time;
    option.length = length;
    this.setData({
      option: option,
      receiver: receiver
    })
  },

  //跳转去观看
  towatch: function (event) {
    var id = event.currentTarget.dataset.id;
    var mediaType = event.currentTarget.dataset.mediaType;
    console.log(id)
    console.log(mediaType)
    if (mediaType == 'AUDIO') {
      wx.navigateTo({
        url: '../audioAlbumDetail/audioAlbumDetail?id=' + id
      })
    } else {
      wx.navigateTo({
        url: '../videoAlbumDetail/videoAlbumDetail?id=' + id
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})